package com.example.leetcode.linkedlist;

import com.example.leetcode.linkedlist.common.LinkedListUtils;
import com.example.leetcode.linkedlist.common.ListNode;

import java.util.List;

public class leetcode86 {
    public static void main(String[] args) {
        int[] list = {1, 4, 3, 2, 5, 2};
        int x = 3;
        ListNode head = LinkedListUtils.generateLinkedListByArray(list);

        Solution solution = new Solution();
        ListNode node = solution.partition(head, x);

        List<Integer> vals = LinkedListUtils.getLinkedListVals(node);
        System.out.println(vals);
    }

    /**
     * Definition for singly-linked list.
     * public class ListNode {
     *     int val;
     *     ListNode next;
     *     ListNode() {}
     *     ListNode(int val) { this.val = val; }
     *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
     * }
     */
    static class Solution {
        public ListNode partition(ListNode head, int x) {
            return LinkedListUtils.partition(head, x);
        }
    }
}
